<?php
declare(strict_types=1);
namespace App\Controller\Cash\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Middleware;
use App\Middleware\CashMiddleware;
use Service\AreaService\AreaService;

/**
 * 行政区域
 * @author Luoshumai
 * @Controller(prefix="/cash/v1/common")
 * @Middleware(CashMiddleware::class)
 */
class CommonController extends AbstractController
{
    /**
     * @Inject
     * @var AreaService
     */
    protected $areaService;

    /**
     * 获取下级行政区域接口
     * @RequestMapping(path="getarea", methods="post")
     */
    public function getArea(RequestInterface $request)
    {
        return $this->areaService->getArea((int)$request->input('pid'));
    }

    /**
     * 根据 区域id获取信息接口
     * @RequestMapping(path="getareabyid", methods="post")
     */
    public function getAreabyId(RequestInterface $request) {
        return $this->areaService->getAreaInfo((int)$request->input('id'));
    }
}